package example.avro

import java.io.File

import org.apache.avro.file.DataFileReader
import org.apache.avro.io.DatumReader
import org.apache.avro.specific.SpecificDatumReader

object DeserilizingUser {
  def main(args: Array[String]): Unit = {
    val userDatumReader: DatumReader[User] = new SpecificDatumReader[User]()
    val dataFileReader: DataFileReader[User] = new DataFileReader[User](new File("users_sample.avro"), userDatumReader)
    var user: User = null
    while (dataFileReader.hasNext) {
      user = dataFileReader.next(user)
      println(user)
    }
    dataFileReader.close()
  }
}
